import { defineStore } from 'pinia';

interface ObjectList {
    [key: string]: string[];
}

export const usePermissStore = defineStore('permiss', {
    state: () => {
        const defaultList: ObjectList = {
            admin: [
                '0',
                '7',
                '9',
                'B',
                'D',
                'F',
                'G',
                'H',
            ],
            user: ['0', '8' ,'A','C','D'],
            coach: ['0','D','H','G'],
        };
        const username = localStorage.getItem('vuems_name');
        console.log(username);
        if (username == 'admin') {
            return {
                key: (defaultList.admin) as string[],
                defaultList,
            };
        } else if (username == 'coach') {
            return {
                key: (defaultList.coach) as string[],
                defaultList,
            };
        } else {
            return {
                key: (defaultList.user) as string[],
                defaultList,
            };
        }
    },
    actions: {
        handleSet(val: string[]) {
            this.key = val;
        },
    },
});
